home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / modems / mod_a2l / cat_file / cat_file.bts next >
Encoding:
Text File  |  1995-05-02  |  2.0 KB  |  62 lines

  1. //Copy a document file to the STalker terminal window.  Modified by Scott
  2. //Dowdle and Bob Morrow to allow for pauses in the scrolling.  The
  3. //original version would simply scroll on to the end of the file.
  4.  
  5.  
  6. function show_file(string file)
  7.      string    buffer[256];
  8.      int       fd;
  9.      int       linecount;
  10.      int       whatnow;
  11.  
  12.      if (fd = file_open(file, 0)) < 0 then
  13.           printf("Error %d opening '%s'\r\n", fd, file);
  14.         return;
  15.      endif
  16.  
  17.      linecount = 0;
  18.  
  19.     while file_gets(buffer, sizeof(buffer), fd) > 0 do
  20.         linecount = linecount + 1;
  21.         if (linecount == 19) then //Change this to 20 if you don't use
  22.                               //the horizontal scroll bar in STalker.
  23.              printf("---More?  [Q to quit] ---\r\n");
  24.              whatnow = getchar();
  25.                   if (whatnow == 113) then
  26.                         //113 =  Decimal value for q.  Change that to 81
  27.                         //if you want to use Q (CAPS).  Change that to 
  28.                         //120 if you want to use x.  Don't forget to 
  29.                         //change line 23 as well!
  30.                        file_close(fd);
  31.                        return;
  32.                   endif
  33.              linecount = 0;
  34.         endif
  35.         puts(buffer);
  36.     endwhile
  37.     file_close(fd);
  38.  
  39. endfunction
  40.  
  41.  
  42. function main()
  43.     string  source_file[14];
  44.     string  source_full[128];
  45.     string  source_path[128];
  46.  
  47.      source_path[0] = file_get_drive();
  48.      source_path[1] = ':';
  49.      file_get_dir(0, source_path + 2);
  50.      strcat(source_path, "\\*.DOC");  //You can change it to *.* or 
  51.                                       //whatever.
  52.      source_file[0] = 0;
  53.  
  54.      while fsel(source_path,source_file,source_full,"File to Display?")do
  55.           if source_file[0] == 0 then
  56.                return;
  57.           endif
  58.  
  59.           show_file(source_full);
  60.      endwhile
  61. endfunction
  62.